home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-15 | 8.8 KB | 365 lines | [TEXT/ALFA] |
- #== (nowrap) =================================================================
- # Window handling routines. All procs are bound in AlphaBits.tcl.
- #=============================================================================
-
- proc shrinkHigh {} {
- global tileTop tileWidth
- set text [getGeometry]
- set left [lindex $text 0]
- set top [lindex $text 1]
- sizeWin $tileWidth 160
- moveWin $left $tileTop
- }
-
- proc shrinkLow {} {
- global tileHeight tileWidth tileLeft tileTop
- sizeWin $tileWidth 160
- moveWin $tileLeft [expr $tileTop + $tileHeight - 160]
- }
-
- proc singlePage {} {shrinkFull}
-
- proc shrinkFull {} {
- global tileTop tileHeight tileLeft
- moveWin $tileLeft $tileTop
- sizeWin 510 $tileHeight
- }
-
- proc shrinkLeft {} {
- global tileWidth tileTop tileHeight tileLeft
-
- set margin 4
- set width [expr ($tileWidth/2)-$margin]
- set text [getGeometry]
- set width [expr ($tileWidth/2)-$margin]
- set width [expr {$width + $margin / 2}]
- moveWin $tileLeft $tileTop
- sizeWin $width $tileHeight
- }
-
- proc shrinkRight {} {
- global tileWidth tileTop tileHeight tileLeft
-
- set margin 4
- set width [expr ($tileWidth/2)-$margin]
- set text [getGeometry]
- set width [expr ($tileWidth/2)-$margin]
- set width [expr {$width + $margin / 2}]
- moveWin [expr $tileLeft + $width + $margin] $tileTop
- sizeWin $width $tileHeight
- }
-
- proc swapWithNext {} {
- set files [winNames -f]
- if {[llength $files] < 2} return
- bringToFront [lindex $files 1]
- }
-
-
-
- proc nextWindow {} {
- global winActive
- set files [winNames -f]
- if {[llength $files] < 2} {return}
- set f [lindex $files 0]
- set aind [lsearch $winActive $f]
- if {$aind < 0} {error "No win '$f'"}
- set rng [lrange $winActive 0 [expr $aind-1]]
- set winActive [concat [lrange $winActive $aind end] $rng]
- set winActive [lrange $winActive 1 end]
- lappend winActive $f
- bringToFront [lindex $winActive 0]
- }
-
-
- proc prevWindow {} {
- global winActive
- set files [winNames -f]
- if {[llength $files] < 2} {return}
- set f [lindex $files 0]
- set aind [lsearch $winActive $f]
- if {$aind < 0} {error "No win '$f'"}
- set rng [lrange $winActive 0 [expr $aind-1]]
- set winActive [concat [lrange $winActive $aind end] $rng]
- set f2 [lindex [lrange $winActive end end] 0]
- set winActive [lreplace $winActive end end]
- set winActive [linsert $winActive 0 $f2]
- bringToFront $f2
- }
-
- proc bufferOtherWindow {} {
- global tileHeight tileTop tileWidth tileMargin
- global numWinsToTile
- set margin $tileMargin
- set win [car [winNames -f]]
- set numWins 2
- set hor 2
- set height [expr ($tileHeight/$numWins)-$margin]
- set height [expr {$height + $margin / $numWins}]
- set width $tileWidth
- set ver $tileTop
-
- if {[llength [winNames]] < 2} {message "No other window!"; return}
- set next [nextWin]
- set res [statusPrompt "Window other half ($next): " winComp]
- if {![string length $res]} {
- set res $next
- }
-
- set geo [getGeometry]
- if {([lindex $geo 2] != $width) || ([lindex $geo 3] != $height) || ([lindex $geo 0] != $hor) || (([lindex $geo 1] != $ver) && ([lindex $geo 1] != [expr $ver + $height + $margin]))} {
- moveWin $win 1000 0
- sizeWin $win $width $height
- moveWin $win $hor $ver
- incr ver [expr $height + $margin]
- } else {
- if {[lindex $geo 1] == $ver} {
- incr ver [expr $height + $margin]
- }
- }
-
- set geo [getGeometry $res]
- if {([lindex $geo 0] != $hor) || ([lindex $geo 1] != $ver) || ([lindex $geo 2] != $width) || ([lindex $geo 3] != $height)} {
- moveWin $res 1000 0
- sizeWin $res $width $height
- moveWin $res $hor $ver
- }
- bringToFront $res
- }
-
-
-
-
-
- proc winvertically {} {
- global tileHeight tileTop tileWidth tileMargin
- global numWinsToTile
- set margin $tileMargin
- set names [winNames -f]
- set numWins [llength $names]
- if ($numWins<=1) return
- if ($numWins>$numWinsToTile) {set numWins $numWinsToTile}
- set height [expr ($tileHeight/$numWins)-$margin]
- set height [expr {$height + $margin / $numWins}]
- set width $tileWidth
- set ver $tileTop
- if {$numWins == 0} {return}
-
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $names $i] 1000 0
- sizeWin [lindex $names $i] $width $height
- }
-
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $names $i] 2 $ver
- set ver [expr $ver+$margin+$height]
- }
- }
-
- proc winhorizontally {} {
- global tileHeight tileWidth tileTop numWinsToTile horMargin
-
- set names [winNames -f]
- set numWins [llength $names]
- if ($numWins<=1) return
- if ($numWins>$numWinsToTile) {set numWins $numWinsToTile}
- set width [expr ($tileWidth/$numWins)-$horMargin]
- set width [expr {$width + $horMargin / $numWins}]
- set height $tileHeight
- set hor 2
- if {$numWins == 0} {return}
-
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $names $i] 1000 0
- sizeWin [lindex $names $i] $width $height
- }
-
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $names $i] $hor $tileTop
- set hor [expr $hor+$width+$horMargin]
- }
- }
-
-
- proc winunequalHor {} {
- global tileLeft tileHeight tileWidth tileTop numWinsToTile horMargin tileProportion
- set names [winNames -f]
-
- moveWin [car $names] 1000 0
- sizeWin [car $names] [expr $tileProportion*$tileWidth - $horMargin] $tileHeight
- moveWin [car $names] $tileLeft $tileTop
-
- moveWin [cadr $names] 1000 0
- sizeWin [cadr $names] [expr (1-$tileProportion)*$tileWidth - $horMargin] $tileHeight
- moveWin [cadr $names] [expr $tileLeft + $tileProportion*$tileWidth] $tileTop
- }
-
-
- proc winunequalVert {} {
- global tileLeft tileMargin tileHeight tileWidth tileTop numWinsToTile horMargin tileProportion
- set names [winNames -f]
- set height [expr $tileHeight + $tileMargin]
-
- moveWin [car $names] 1000 0
- sizeWin [car $names] $tileWidth [expr $tileProportion*$height - $tileMargin]
- moveWin [car $names] $tileLeft $tileTop
-
- moveWin [cadr $names] 1000 0
- sizeWin [cadr $names] $tileWidth [expr (1-$tileProportion)*$height - $tileMargin]
- moveWin [cadr $names] $tileLeft [expr $tileTop + $tileProportion*$height]
- }
-
-
- proc wintiled {} {
- global tileHeight tileWidth numWinsToTile tileTop
- set xPan 8
- set yPan 10
- set xMarg 2
- set yMarg $tileTop
- set yMax 50
- set names [winNames -f]
- set numWins [llength $names]
- if ($numWins<1) return
- set line 0
- set height [expr $tileHeight-$yPan*($numWins-1)]
- set width [expr $tileWidth-$xPan*($numWins-1)]
-
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $names $i] [expr $xMarg+$i*$xPan] [expr $yMarg+$line]
- set line [expr $line+$yPan]
- if ($line>$yMax) {set line 0}
- sizeWin [lindex $names $i] $width $height
- }
- }
-
-
- proc winoverlay {} {
- global defHeight defWidth numWinsToTile tileTop
- set names [winNames -f]
- set numWins [llength $names]
- if ($numWins<1) return
- for {set i 0} {$i < $numWins} {incr i} {
- moveWin [lindex $names $i] 2 $tileTop
- sizeWin [lindex $names $i] $defWidth $defHeight
- }
- }
-
-
- proc chooseAWindow {} {
- set name [listpick [lsort -ignore [winNames]]]
- if {[string length $name]} {
- bringToFront $name
- if [icon -q] { icon -f $name -o }
- }
- }
-
-
- proc nextWin {} {
- global winActive
- set files [winNames -f]
- if {[llength $files] < 2} {return ""}
- set f [lindex $files 0]
- set aind [lsearch $winActive $f]
- if {$aind < 0} {error "No win '$f'"}
- if {[incr aind] < [llength $winActive]} {
- return [file tail [lindex $winActive $aind]]
- } else {
- return [file tail [lindex $winActive 0]]
- }
- }
-
- proc winComp {curr c} {
- if {$c != "¥t"} {return $c}
-
- set matches {}
- foreach w [winNames] {
- if {[string match "$curr*" $w]} {
- lappend matches $w
- }
- }
- if {![llength $matches]} {
- beep
- } else {
- return [string range [largestPrefix $matches] [string length $curr] end]
- }
- return ""
- }
-
- proc killWindowStatus {} {
- if {![llength [winNames]]} return
-
- set def [lindex [winNames] 0]
- set res [statusPrompt "Kill window ($def): " winComp]
-
- if {[string length $res]} {
- catch {bringToFront $res; killWindow}
- } else {killWindow}
- }
-
- proc chooseWindowStatus {} {
- if {[llength [winNames]] < 2} {message "No other window!"; return}
- set next [nextWin]
- set res [statusPrompt "Window ($next): " winComp]
- if {[string length $res]} {
- catch {bringToFront $res}
- } else {
- catch {bringToFront $next}
- }
- }
- # bind f9 chooseWindowStatus
-
- proc iconify {} {
- icon -t
- if {[icon -q]} {
- nextWindow
- }
- }
-
-
-
- proc zoom {} {
- global nzmState tileHeight tileWidth zoomedGeo tileTop tileLeft
-
- set win [car [winNames -f]]
- if {[info exists nzmState($win)]} {
- if {[getGeometry] == $zoomedGeo} {
- set state $nzmState($win)
- moveWin [lindex $state 0] [lindex $state 1]
- sizeWin [lindex $state 2] [lindex $state 3]
- unset nzmState($win)
- return
- }
- }
-
- set nzmState($win) [getGeometry]
- moveWin $tileLeft $tileTop
- sizeWin $tileWidth $tileHeight
-
- if {![info exists zoomedGeo]} {
- set zoomedGeo [getGeometry]
- }
- }
-
- #================================================================================
-
- proc otherThing {} {
- set win [car [winNames -f]]
- getWinInfo -w $win arr
- if {$arr(split)} {
- otherPane
- } else {
- swapWithNext
- }
- }
-
- proc winAttribute {att {win {}}} {
- if {![string length $win]} {
- set win [car [winNames -f]]
- }
- getWinInfo -w $win arr
- return $arr($att)
- }
-
-
-
-